<script setup>
import { onMounted, reactive } from 'vue';

const state = reactive({
  dataList: []
})
onMounted(() => {
  chrome.storage.local.get('dataList', (data) => {
    state.dataList = data.dataList
    console.log('Data retrieved in Vue component:', data.dataList);
  });
})
</script>

<template>
  <div class="container">
    <a :href="item.link" class="newsList" v-for="(item, index) in state.dataList" :key="index">
      <div class="left">
        <img class="img" :src="item.imgUrl" alt="">
        <div class="center">
          <div class="title">{{ item.title }}</div>
          <div class="subTitle">{{ item.subtitle }}</div>
        </div>
      </div>
      <div class="right">
        <span class="hotindex">{{ item.hotIndex }}</span>
        <span class="hotTxt">热搜指数</span>
      </div>
    </a>
  </div>
</template>

<style>
.container {
  padding: 18px 5px;
  min-width: 622px;
}
.newsList {
  text-decoration: none;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
}
.left{
  display: flex;
  align-items: center;
}
.img {
  flex-shrink: 0;
  max-width: 128px;
  max-height: 85px;
  border-radius: 12px;
  background-color: #fff;
  display: inline-block;
  margin-right: 16px;
}

.title {
  font-size: 18px;
  color: #222;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.subTitle {
  font-size: 13px;
  color: #626675;
  line-height: 20px;
  overflow: hidden;
  /* margin: 0 150px 0 96px; */
  font-size: 13px;
  color: #626675;
}
.right{
  width: 150px;
  flex-shrink: 0;
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  
}
.hotTxt{
  padding-top: 10px;
}
</style>

